package com.wunu.smartlock1.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.wunu.smartlock1.R;
import com.wunu.smartlock1.activity.LockRecordActivity;
import com.wunu.smartlock1.model.AuthorizedMemberVo;
import com.wunu.smartlock1.model.AuthorizedRecordVo;

import java.util.List;

/**
 * Created by admin on 2018/4/22.
 */

public class AuthorizedRecordAdapter extends ArrayAdapter {
    private int resourceId;
    public AuthorizedRecordAdapter(Context context, int textViewResourceId, List<AuthorizedRecordVo> list){
        super(context, textViewResourceId, list);
        resourceId = textViewResourceId;
    }
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        AuthorizedRecordVo memberVo = (AuthorizedRecordVo) getItem(position); // 获取当前项的Fruit实例
        View view = LayoutInflater.from(getContext()).inflate(resourceId, null);//实例化一个对象 使用Inflater对象来将布局文件解析成一个View

        TextView authorizedCode = (TextView) view.findViewById(R.id.authorizedCode);//获取该布局内的文本视图
        TextView authorizedName = (TextView) view.findViewById(R.id.authorizedName);//获取该布局内的文本视图
        TextView lockStatus = (TextView) view.findViewById(R.id.lockStatus);//获取该布局内的文本视图
        TextView lockTime = (TextView) view.findViewById(R.id.lockTime);//获取该布局内的文本视图
        ImageView authorizedPicUrl = (ImageView) view.findViewById(R.id.authorizedPicUrl);//获取该布局内的图片视图authorizedPicUrl


        authorizedCode.setText(memberVo.getAuthorizedCode());//为文本视图设置文本内容
        authorizedName.setText(memberVo.getAuthorizedName());//为文本视图设置文本内容
        lockStatus.setText(memberVo.getLockStatus());//为文本视图设置文本内容
        lockTime.setText(memberVo.getlockTime());//为文本视图设置文本内容
        authorizedPicUrl.setImageResource(memberVo.getAuthorizedPicUrl());//为图片视图设置图片资源
        return view;
    }
}
